package com.gy.smart.home.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gy.smart.R;
import com.gy.smart.life.bean.LifeListBean;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * 作者：gy on 17/1/3
 * 说明：首页本地特惠
 */
public class HomeLifeAdapter extends BaseAdapter {

    private Context context;
    private List<LifeListBean> list;

    public HomeLifeAdapter(Context context,List<LifeListBean> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.adapter_home_life,null);
        ImageView imgShop = (ImageView) convertView.findViewById(R.id.adapter_home_life_img);
        TextView tvName = (TextView) convertView.findViewById(R.id.adapter_home_life_tv_name);
        TextView tvPriceNow = (TextView) convertView.findViewById(R.id.adapter_home_life_tv_price_new);
        TextView tvPriceOld = (TextView) convertView.findViewById(R.id.adapter_home_life_tv_price_old);
        tvPriceOld.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG );

        ImageLoader.getInstance().displayImage(list.get(position).shop_img_url,imgShop);
        tvName.setText(list.get(position).title);

        return convertView;
    }
}
